//package org.jeecg.modules.paycenter.channel.tonglian;
//
//import com.alibaba.fastjson.JSONObject;
//import org.apache.commons.lang.StringUtils;
//import org.jeecg.common.api.vo.Result;
//import org.jeecg.common.exception.JeecgBootException;
//import org.jeecg.modules.paycenter.enums.PayChannelEnum;
//import org.jeecg.modules.paycenter.enums.UTypeEnum;
//import org.jeecg.modules.paycenter.service.IMemberChannelService;
//import org.jeecg.modules.wlhy.hydriver.entity.HyDriver;
//import org.jeecg.modules.wlhy.tlaccount.entity.HyTlAccount;
//import org.jeecg.modules.wlhy.tlaccount.service.IHyTlAccountService;
//import org.jeecg.modules.wlhy.utils.HyCfgUtil;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.math.BigDecimal;
//
//@Service
//public class TongLianMemberChannelService implements IMemberChannelService {
//
//    private IHyTlAccountService tlAccountService;
//
//    @Override
//    public PayChannelEnum getChannelEnum() {
//        return PayChannelEnum.TONGLIAN;
//    }
//
//    @Override
//    public boolean checkChannel() {
//        return HyCfgUtil.isUsed2("tonglian");
//    }
//
//    @Override
//    public Result<?> getDriverAccount(HyDriver driver) {
////        HyTlAccount account = tlAccountService.getByBizUserIdForUpdate(driver.getId());
////        if(account == null){
////            return Result.error("未开通钱包");
////        }
////        try {
////            JSONObject memberInfo = TongLianUtil.getMemberInfo(driver.getId());
////            if(TongLianUtil.isSuccess(memberInfo)){
////                account.setMemberInfo(memberInfo);
////            }else {
////                account.setMsg(TongLianUtil.getMsg(memberInfo));
////            }
////        }catch (Exception ex){
////            account.setMsg(ex.getMessage());
////        }
////        return Result.OK(account);
//        return Result.error("todo");
//    }
//
//    @Override
//    @Transactional
//    public Result<?> createDriverAcccount(HyDriver driver, JSONObject data) {
////        //检查是否已开通
////        String bizUserId = driver.getId();
////        HyTlAccount account = tlAccountService.getByBizUserIdForUpdate(bizUserId);
////        if(account != null){
////            return Result.error("已开通钱包,不能重复开通");
////        }
////        String carNo = data.getString("carNo");
////        if(StringUtils.isEmpty(carNo)){
////            return Result.error("车牌号不能为空");
////        }
////
////        String source = data.getString("source");
////        if(StringUtils.isEmpty(source)){
////            source = "2"; //1：手机 2：PC
////        }
////
////        account = new HyTlAccount();
////        account.setUtype(UTypeEnum.getUType(UTypeEnum.DRIVER));
////        account.setBizUserId(bizUserId);
////        account.setUid(bizUserId);
////        account.setSt("1");
////        account.setIzOpen("1");
////        account.setAmt(BigDecimal.ZERO);
////        account.setAvailAmt(BigDecimal.ZERO);
////        account.setFrzAmt(BigDecimal.ZERO);
////        tlAccountService.save(account);
////        JSONObject ret = TongLianUtil.createPersonMember(bizUserId, driver.getDriverName(), driver.getIdcard(), "2", driver.getTelephone(), carNo , source);
////        if(!TongLianUtil.isSuccess(ret)){
////            throw new JeecgBootException("开通失败," + TongLianUtil.getMsg(ret));
////        }
////        JSONObject jd = ret.getJSONObject("data");
////        String tlUserId = jd.getString("userId");//云商通会员号
////        account.setTlUserId(tlUserId);
////        tlAccountService.updateById(account);
////        return Result.OK("开通成功!");
//        return Result.error("todo");
//    }
//}
